<?
/**
 * Copyright 2008 Melange.
 *
 * This file is part of Melange CMS
 *
 * @package cms
 *
 */


/**
 * Requirements
 */
require_once("mvc/action/ActionForm.php");
require_once("mvc/action/ActionMessage.php");
require_once("mvc/action/ActionMessages.php");
require_once("cms/forum/om/TopicReply.php");



/**
 * BaseReplyForm Class
 *
 * @category    Melange CMS
 * @package     cms
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 */
class BaseReplyForm extends ActionForm {


    // ----------------------------------------------------- Instance Variables


    /**
     * reply
     *
     * @var TopicReply 
     */
    protected $reply;


    // ----------------------------------------------------------- Constructors


    /**
     * Construct new BaseReplyForm
     */
    public function __construct() {
        $this->reply = new TopicReply();
    }


    // ------------------------------------------------------------- Properties


    /**
     * Get Reply
     *
     * @return TopicReply 
     */
    public function getReply() {
        return $this->reply;
    }


    /**
     * Set Reply
     *
     * @param TopicReply  reply
     */
    public function setReply(TopicReply $reply) {
        $this->reply = $reply;
    }


    // --------------------------------------------------------- Public Methods


    /**
     * Validate this form
     *
     * @return array $errors
     */
    public function validate() {

        $errors = new ActionMessages();

        if(is_null($this->getReply()->getBody()) || strlen($this->getReply()->getBody()) == 0)
            $errors->add("reply->body",
                new ActionMessage("errors.required", true, new ActionMessage("prompt.body", true)));


        return $errors;
    }

}
?>